Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data parameters #28

Merged
merged 37 commits into from
Jun 23, 2024
Merged

Conversation

ElySeraidarian
Copy link
Collaborator

@ElySeraidarian ElySeraidarian commented Jun 5, 2024

This PR aims to follow the process of solving issue #25.

Data parameters added:

  • use_relative
  • flipped
  • order_descending
  • order_tree
  • add.significance
  • add.expl.var

Current issues :

  • confidence.level (RDAPlot) is a numeric between 0 and 1, so I'm using a sliderInput but even after adding step parameter there is only 0 and 1 that can be selected, moreover it doesn't seem to change anything on the plot either.

  • shape_by (AbundanceDensityPlot) should be hidden when layout="density", the only method for this looks to be .conditionOnRadio but it should only work on radiobuttons & checkboxes (not selectInput). I have two solutions : creating a method for selectinputs or change the selectinput in radiobuttons?

Still to implement :

  • order_sample_by
  • decreasing
  • Visual params for both RDAPlot & RowTreePlot

Note : Have to be using the GitHub version of miaViz

Copy link
Member

@RiboRings RiboRings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! I added some points that can be improved. Also you might need to update the unit tests since there are new parameters now

R/class-AbundanceDensityPlot.R Outdated Show resolved Hide resolved
R/class-AbundanceDensityPlot.R Outdated Show resolved Hide resolved
R/class-AbundanceDensityPlot.R Show resolved Hide resolved
R/class-AbundanceDensityPlot.R Outdated Show resolved Hide resolved
R/class-AbundancePlot.R Outdated Show resolved Hide resolved
R/class-RDAPlot.R Outdated Show resolved Hide resolved
R/class-RDAPlot.R Outdated Show resolved Hide resolved
R/class-RowTreePlot.R Outdated Show resolved Hide resolved
R/class-RowTreePlot.R Outdated Show resolved Hide resolved
R/class-AbundanceDensityPlot.R Outdated Show resolved Hide resolved
@ElySeraidarian
Copy link
Collaborator Author

ElySeraidarian commented Jun 12, 2024

I have corrected the issues and added the last data parameters.
I still have still have one issue for order_sample_by, we should also be able to use a class from the different taxonomy ranks , for example :
plotAbundance(se, assay.type="relabundance", rank = "Phylum", order_rank_by="abund", order_sample_by = "Bacteroidetes")
However when I try this I get an error saying it is not in the abundance data.

Moreover, for the visual parameters for RDAPlot/RowTreePlot (tip_size_by/edge_size_by/node_size_by). It is needed to perform some modification to the data pefore plotting so I don't know if this is something to be added (also how).
For example :
data(GlobalPatterns)
altExps(GlobalPatterns) <- splitByRanks(GlobalPatterns)
altExp(GlobalPatterns,"Genus") <- addPerFeatureQC(altExp(GlobalPatterns,"Genus"))
rowData(altExp(GlobalPatterns,"Genus"))$log_mean <- log(rowData(altExp(GlobalPatterns,"Genus"))$mean)
rowData(altExp(GlobalPatterns,"Genus"))$detected <- rowData(altExp(GlobalPatterns,"Genus"))$detected / 100
top_genus <- getTopFeatures(altExp(GlobalPatterns,"Genus"), method="mean", top=100L, assay.type="counts")
x <- altExp(GlobalPatterns,"Genus")
plotRowTree(x[rownames(x) %in% top_genus,], tip_colour_by = "log_mean", tip_size_by = "detected")

@RiboRings
Copy link
Member

Nice progress!

For the size parameters of RDAPlot and RowTreePlot, we can just provide the parameter without adding code. Note that a simple example like this also works:

library(mia)
library(miaViz)
data("Tengeler2020", package = "mia")

tse <- addPerFeatureQC(tse)
plotRowTree(tse, tip_size_by = "mean")

If you think that some more advanced usage should be explained (like the code you wrote above), the right place is in vignettes/ as a separate Rmd file. For example, see the Articles section in the iSEE documentation.

@RiboRings
Copy link
Member

plotAbundance(tse, assay.type="relabundance", rank = "Phylum", order_rank_by="abund", order_sample_by = "Bacteroidetes") actually works for me with Tengeler2020. Are you using a different dataset?

Could you add a third option "Row data" here? Even if it throws an error, but at least we can test it.

Screenshot 2024-06-12 at 20 19 21

@ElySeraidarian
Copy link
Collaborator Author

ElySeraidarian commented Jun 13, 2024

I have added example for Row data so I'll explain what's the issue:
choices=unique(rowData(se)$Phylum)
For example here I've added this line as choices for the selectInput, to be able to use it and that the app doesn't crash you need to firstly select "Phylum" rank in the visual parameters and then it will work. So here is the issue : we should update this list each time the rank changes so that it follows the right possible values.

@ElySeraidarian
Copy link
Collaborator Author

Now all the visual parameters should have been added in both RDAPlot & RowTreePlot (maybe there can be a better way to sort these parameters in RowTreePlot, I can rework this).

@ElySeraidarian
Copy link
Collaborator Author

By the way, I have spotted another issue for the order_sample_by : if you try to change the taxonomic rank and access to Column data, the app will crash (looks like this is because there is a conflict between order_sample_by rank and the taxonomic rank selected, e.g. selecting in row data a family name from the taxonomic rank you'd like to change then changing to Column data will work fine)

Fixed.

@RiboRings
Copy link
Member

RiboRings commented Jun 14, 2024

Now all the visual parameters should have been added in both RDAPlot & RowTreePlot (maybe there can be a better way to sort these parameters in RowTreePlot, I can rework this).

Ideally, we would like to adjust, say, line colour, while keeping line size unchanged. But in the current configuration one cannot activate "colour by" without also activating "shape by", or "size by". Probably the checkbox solution (colour, shape, size) as in the RDAPlot panel could fix this.

@ElySeraidarian
Copy link
Collaborator Author

I have made changes for checkboxes but there are still issues :

  • After you have enabled the checkbox, for some reasons even if you uncheck, the changes will be kept
  • If enabling/disabling several times in a row checkboxes, app will crash stating that length of if statement is too long

@RiboRings
Copy link
Member

I have made changes for checkboxes but there are still issues :

  • After you have enabled the checkbox, for some reasons even if you uncheck, the changes will be kept
  • If enabling/disabling several times in a row checkboxes, app will crash stating that length of if statement is too long

At least the first issue is likely due to this: say you turn on colour, set it to blue, and turn it off. Once you turn it off, the conditional in the .generateOutput method will return FALSE so colour will not be changed (will stay blue). Thus, we might need to look how it is done originally in the source code of iSEE visual box, or come up with something smart ourselves.

@ElySeraidarian
Copy link
Collaborator Author

I have made changes for checkboxes but there are still issues :

  • After you have enabled the checkbox, for some reasons even if you uncheck, the changes will be kept
  • If enabling/disabling several times in a row checkboxes, app will crash stating that length of if statement is too long

At least the first issue is likely due to this: say you turn on colour, set it to blue, and turn it off. Once you turn it off, the conditional in the .generateOutput method will return FALSE so colour will not be changed (will stay blue). Thus, we might need to look how it is done originally in the source code of iSEE visual box, or come up with something smart ourselves.

In the reducedDimPlot there is quite the same issue (except that sometimes there is a conditional radio button after turning on the checkbox so it can be disabled), but app shouldn't crash at least

@RiboRings
Copy link
Member

RiboRings commented Jun 17, 2024

Right! Two things:

  1. Any configuration is ok as long as aesthetics for different components (lines, tips and nodes) are independent from each other, that is, it is possible to select line colour/size/shape without activating or affecting node colour/size/shape
  2. The error occurs when two or more boxes are checked (for example, colour + size). So probably .conditionalOnCheckGroup can only take one input at a time. In the source code of visual box they seem to use something different, which is worth checking out: https://github.com/iSEE/iSEE/blob/8f32b92fb8343bc77a16988cc3afc70d65b961fb/R/interface_visual.R#L70

@ElySeraidarian
Copy link
Collaborator Author

Everything should be working I believe now, let me know if you find anything wrong still

@RiboRings
Copy link
Member

RiboRings commented Jun 18, 2024

Thank you! We are getting closer.

We would like also colour, size and shape of, say, node to be independent from each other, so that we can colour nodes without turning on their size. How about the following configuration? (sorry for switching again)

[ ] Color [ ] Shape [ ] Size

Color by:
[ ] line [ ] tip [ ] node

Shape by:
[ ] tip [ ] node

Size by:
[ ] line [ ] tip [ ] node

By default, nothing is active. When you turn on for example colour, you will see options line, tip and node. You can choose to colour only one of them, or more, but once you turn off the corresponding checkbox, say line, the colour of line should go back to default (turn off line colour).

It's a good idea to build it up gradually and make sure it works for a smaller subset of params. If it does, then scale it up to all remaining options.

Do you think this can be a good solution? Let me know if you need any help.

Btw, currently colour is working only for edge and not for line and tip.

@RiboRings
Copy link
Member

Also if you want maybe you could add yourself to the contributors in DESCRIPTION?

@ElySeraidarian
Copy link
Collaborator Author

ElySeraidarian commented Jun 19, 2024

The rework has been made, there shouldn't be any crash and should be operational.
The only thing is that when desactivating a checkbox it won't disable instantly the parameter (will do it when activating another checkbox). I don't know if this can be fixed somehow

@ElySeraidarian
Copy link
Collaborator Author

The rework has been made, there shouldn't be any crash and should be operational. The only thing is that when desactivating a checkbox it won't disable instantly the parameter (will do it when activating another checkbox). I don't know if this can be fixed somehow

Like it does not refresh the plot when desactivating a checkbox which is probably the reason behind

@RiboRings
Copy link
Member

Ok, I think it's good to go. If we find a solution to turn off aesthetics we can add it in the future. Let's fix the checks and then we can merge.

@ElySeraidarian
Copy link
Collaborator Author

Ok, I think it's good to go. If we find a solution to turn off aesthetics we can add it in the future. Let's fix the checks and then we can merge.

Tests somehow fail in the github workflow but all tests were successful locally, probably takes the previous tests version

@RiboRings
Copy link
Member

Tests are probably failing because we are using the GitHub version of miaViz. @TuomasBorman, when will it be pushed to bioconductor devel?

@TuomasBorman
Copy link

There are big changes both in mia and miaViz. I pushed now, but there might occur some issues since miaViz is not yet synced with mia

@RiboRings RiboRings merged commit 4ca1239 into microbiome:devel Jun 23, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants